package com.tanglongan.designPattern.dp06_adapter.demo02_object;

/**
 * 对象适配器的原理就是通过组合来实现适配器的功能。
 * 说先让Adapter实现Itarget接口，然后内部持有Adaptee实例，最后在Itarget接口规定的方法里转化Adaptee
 */
public class PowerAdapter implements DC5 {
    private final AC220 ac220;

    public PowerAdapter(AC220 ac220) {
        this.ac220 = ac220;
    }

    public int output5V() {
        int adapterInput = ac220.outputAC220();
        int adapterOutput = adapterInput / 44;
        System.out.println("使用Adapter输入AC：" + adapterInput + "V，输出DC：" + adapterOutput + "V");
        return adapterOutput;
    }

}
